import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vitePluginMonacoEditor from 'vite-plugin-monaco-editor'

// 正确处理 CommonJS 模块
const monacoEditorPlugin = (vitePluginMonacoEditor as any).default || vitePluginMonacoEditor

export default defineConfig({
  server: {
    host: '0.0.0.0', // 必须监听所有接口
    port: 5173,
    strictPort: true,
    // 关键修改 👇 添加 allowedHosts 配置
    allowedHosts: [
      'w8de6ad8.natappfree.cc', // 允许特定域名
      '.natappfree.cc'           // 允许 natappfree.cc 下的所有子域名
    ]
  },
  plugins: [
    vue(),
    monacoEditorPlugin({
      languages: ['cpp', 'java', 'python', 'javascript'],
      features: [
        'bracketMatching',
        'hover',
        'format',
        'suggest',
        'quickFix',
        'codeAction',
        'codelens',
        'inlineHints',
        'rename',
        'wordHighlighter'
      ]
    })
  ],
  resolve: {
    alias: {
      '@': '/src'
    }
  }
})